package com.nanhai.buddhist.college.module.collegebase.api.room;

import com.nanhai.buddhist.college.framework.common.pojo.CommonResult;
import com.nanhai.buddhist.college.module.collegebase.api.room.dto.RoomRespDTO;
import com.nanhai.buddhist.college.module.collegebase.convert.classroominfo.ClassroomInfoConvert;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.classroominfo.ClassroomInfoDO;
import com.nanhai.buddhist.college.module.collegebase.service.classroominfo.ClassroomInfoService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

import static com.nanhai.buddhist.college.framework.common.pojo.CommonResult.success;
import static com.nanhai.buddhist.college.module.collegebase.enums.ApiConstants.VERSION;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
public class RoomApiImpl implements RoomApi {

    @Resource
    private ClassroomInfoService classroomInfoService;
    @Override
    public CommonResult<List<RoomRespDTO>> getClassroomInfoList(Collection<String> ids) {
        List<ClassroomInfoDO> classroomInfoList = classroomInfoService.getClassroomInfoList(ids);
        return success(ClassroomInfoConvert.INSTANCE.convertList03(classroomInfoList));
    }
}
